The present disclosure generally relates to computing devices, and more particularly to scheduling tasks for execution on one or more processors.
An operating system serves as an intermediary layer between the hardware and software (e.g., an application). An operating system may also schedule tasks for efficient use of system resources and may implement different scheduling policies to determine which tasks to schedule in a work queue for execution on a processor.
In an example, an operating system may implement a first-come first service scheduling policy in which a thread that arrives before another thread is executed before the other thread. The first-come first service scheduling policy, however, has some disadvantages. For example, the first-come first service scheduling policy may yield some long wait times, particularly if the first thread to arrive in a work queue takes a long time. Additionally, although the thread that arrives later may be more urgent, the later arriving thread is executed after the threads on a first-come basis.
In another example, an operating system may implement a round-robin scheduling policy in which a pool of threads take turn executing for a specified period of time. The round-robin scheduling policy, however, has some disadvantages. For example, threads in the pool may have different priorities and one thread may take substantially longer to execute compared to another thread that has a short execution time. Scheduling policies are typically complex to avoid such shortcomings, and implement complex heuristics to prioritize work threads.
Embodiments of the present disclosure and their advantages are best understood by referring to the detailed description that follows. The accompanying drawings, which form a part of the specification, illustrate embodiments of the invention and together with the description, further serve to explain the principles of the embodiments. In the drawings, like reference numbers may indicate identical or functionally similar elements. The drawing in which an element first appears is generally indicated by the left-most digit in the corresponding reference number.